"""
導包
封裝測試套件
指定報告路徑
打開文件流
    創建HTMLTestRunner運行器
    執行測試套件
"""

# 導包
import time
import unittest
from test10_unittest_tvshop import TPShopLogin
from test12_unittest_params import TPShopLogin2
from tools.HTMLTestRunner import HTMLTestRunner

# 封裝測試套件suite
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TPShopLogin))
suite.addTest(unittest.makeSuite(TPShopLogin2))

# 指定報告路徑
report = "./report/report-{}.html".format(time.strftime("%Y%m%d-%H%M%S"))

# 打開文件流
with open(report, "wb") as f:
    # 創建HTMLTestRunner運行器runner
    runner = HTMLTestRunner(f, title="TVShop接口測試報告")
    # 執行測試套件
    runner.run(suite)